package drazing;

import java.awt.Shape;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;

/**
 * Implementa los métodos para el tratamiento de los obstaculos
 * @author xcubo
 */
public class Obstaculo extends Molde
{
    private Shape cuerpo;
    private int tipo;
    private BufferedImage img_src;

    public Obstaculo(Shape s, int type)
    {
        super(s.getBounds2D().getX(),s.getBounds2D().getY());
        cuerpo = s;
        tipo = type;

        switch (tipo)
        {
            case 0:
                try {img_src = ImageIO.read(getClass().getResource("../resources/img/obs/start.png"));}
                catch (IOException e) { System.out.println("Imposible cargar la imagen");}
                break;
            case 1:
                try {img_src = ImageIO.read(getClass().getResource("../resources/img/obs/bridgestone.jpg"));}
                catch (IOException e) { System.out.println("Imposible cargar la imagen");}
                break;
            case 2:
                try {img_src = ImageIO.read(getClass().getResource("../resources/img/obs/bridgestone2.jpg"));}
                catch (IOException e) { System.out.println("Imposible cargar la imagen");}
                break;
            case 3:
                try {img_src = ImageIO.read(getClass().getResource("../resources/img/obs/bridgestone3.jpg"));}
                catch (IOException e) { System.out.println("Imposible cargar la imagen");}
                break;
            case 4:
                try {img_src = ImageIO.read(getClass().getResource("../resources/img/obs/f1.jpg"));}
                catch (IOException e) { System.out.println("Imposible cargar la imagen");}
                break;
            case 5:
                try {img_src = ImageIO.read(getClass().getResource("../resources/img/obs/michelin.jpg"));}
                catch (IOException e) { System.out.println("Imposible cargar la imagen");}
                break;
            case 6:
                try {img_src = ImageIO.read(getClass().getResource("../resources/img/obs/elf.jpg"));}
                catch (IOException e) { System.out.println("Imposible cargar la imagen");}
                break;
            case 7:
                try {img_src = ImageIO.read(getClass().getResource("../resources/img/obs/marl.jpg"));}
                catch (IOException e) { System.out.println("Imposible cargar la imagen");}
                break;
            case 8:
                break;
        }
    }
    @Override
    public double getX()
    {
        return cuerpo.getBounds2D().getX();
    }
    @Override
    public double getY()
    {
        return cuerpo.getBounds2D().getY();
    }
    public double getWidth()
    {
        return cuerpo.getBounds2D().getWidth();
    }
    public double getHeight()
    {
        return cuerpo.getBounds2D().getHeight();
    }
    public Shape getSahpe()
    {
        return cuerpo;
    }
    public BufferedImage getImage()
    {
        return img_src;
    }
    public int getType()
    {
        return tipo;
    }
}
